package sensor;

import org.opencv.highgui.Highgui;

import analysis.BlinkDet;
import analysis.EyeDet;
import analysis.FaceDet;
import analysis.IDetection;
import analysis.VideoCap;
import utils.DateHandler;
import utils.ImageDeted;
import utils.View;

public class Test07 {

	public static void main(String[] args) throws InterruptedException {
		DateHandler dh = new DateHandler();
		ImageDeted id = new ImageDeted();
		IDetection 
				bd = new BlinkDet(), 
				ed = new EyeDet(), 
				fd = new FaceDet(), 
				vc = new VideoCap(3);

		View view = new View(id);

		vc.run(id);

		dh.restart();
		int i = 0;
		while (i++ < 1000) {
			if (dh.nowEnd() > 25) {
				view.update(bd.run(ed.run(fd.run(vc.run(id)))));
				dh.restart();
			}else{
				Thread.sleep(Math.max(dh.nowEnd()-25,10));
			}
		}
		Highgui.imwrite("Results.jpg", id.getImage());

		id.switchOff();
		vc.run(id);

	}

}
